/* GUI CONVERTED from rcsomtb1.p (converter v1.76) Tue Apr 23 11:59:47 2002 */
/* rcsomtb1.p - SALES ORDER DETAIL CONSIGNMENT POP-UP FRAME                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/* $Revision: 1.8 $    */
/*V8:ConvertMode=Maintenance                                                */

/* $Revision: 1.8 $    BY: Patrick Rowan     DATE: 04/04/02 ECO: *P00F* */
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*!
  ----------------------------------------------------------------------------
  DESCRIPTION: This program controls a frame containing consignment variables.

  Notes:
  1.  This program can be used by Maintenance screens, Inquiries, and Reports.
        The input paramter, in_update, indicates that this program should allow
        updates to the variables.
  2.  This program can be used by both Sales Order programs and Scheduled
        Order programs.  The input parameter, in_schedule, indicates that the
        calling program is a Customer Schedule program and will display the
        frame associated with customer schedules.

  ============================================================================
!*/
{mfdeclre.i}
{socnvars.i}
{pxsevcon.i}
{gpcnmsg.i}
{socnsod.i}
{gplabel.i}

/* PARAMETERS */
define input-output parameter table for tt_sod_det.
define input parameter in_update    like mfc_logical no-undo.
define input parameter in_schedule  like mfc_logical no-undo.


define buffer bCustConsignDetailPopup for tt_sod_det.

find first bCustConsignDetailPopup.

assign
   bCustConsignDetailPopup.in_update = in_update
   bCustConsignDetailPopup.in_schedule = in_schedule.

/* FORM STATEMENT: FRAME sod_consign */

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
bCustConsignDetailPopup.sod_consign_loc             colon 26
   bCustConsignDetailPopup.sod_intrans_loc             colon 26
   bCustConsignDetailPopup.sod_max_aging_days          colon 26
 SKIP(.4)  /*GUI*/
with frame sod_consign width 80 side-labels attr-space
 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-sod_consign-title AS CHARACTER.
 F-sod_consign-title = (getFrameTitle("CONSIGNMENT_ORDER_LINE_ITEM_DATA",50)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame sod_consign = F-sod_consign-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame sod_consign =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame sod_consign + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame sod_consign =
  FRAME sod_consign:HEIGHT-PIXELS - RECT-FRAME:Y in frame sod_consign - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME sod_consign = FRAME sod_consign:WIDTH-CHARS - .5. /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame sod_consign:handle).

/* FORM STATEMENT: FRAME sod_consign_sched */

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
bCustConsignDetailPopup.sod_consign_loc             colon 26
   bCustConsignDetailPopup.sod_auto_replenish          colon 60
   bCustConsignDetailPopup.sod_intrans_loc             colon 26
   bCustConsignDetailPopup.sod_max_aging_days          colon 60
 SKIP(.4)  /*GUI*/
with frame sod_consign_sched width 80 side-labels attr-space
 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-sod_consign_sched-title AS CHARACTER.
 F-sod_consign_sched-title = (getFrameTitle("CONSIGNMENT_ORDER_LINE_ITEM_DATA",50)).
 RECT-FRAME-LABEL:SCREEN-VALUE in frame sod_consign_sched = F-sod_consign_sched-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame sod_consign_sched =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame sod_consign_sched + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame sod_consign_sched =
  FRAME sod_consign_sched:HEIGHT-PIXELS - RECT-FRAME:Y in frame sod_consign_sched - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME sod_consign_sched = FRAME sod_consign_sched:WIDTH-CHARS - .5. /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame sod_consign_sched:handle).

run readSalesOrderDetailConsignRecord
    (buffer bCustConsignDetailPopup,
     input {&NO_LOCK_FLAG},
     input {&WAIT_FLAG}).

/* DISPLAY CONSIGNMENT VALUES */
if bCustConsignDetailPopup.in_schedule then
       display
           bCustConsignDetailPopup.sod_consign_loc
           bCustConsignDetailPopup.sod_intrans_loc
           bCustConsignDetailPopup.sod_max_aging_days
           bCustConsignDetailPopup.sod_auto_replenish
           with frame sod_consign_sched.
else
       display
           bCustConsignDetailPopup.sod_consign_loc
           bCustConsignDetailPopup.sod_intrans_loc
           bCustConsignDetailPopup.sod_max_aging_days
           with frame sod_consign.


/* UPDATE CONSIGNMENT VALUES, IF CALLED FROM MAINTENANCE PGM */
if bCustConsignDetailPopup.in_update then do:

       repeatloop:
       do on error undo, retry on endkey undo, leave:
/*GUI*/ if global-beam-me-up then undo, leave.


           setloop:
           do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.


           if bCustConsignDetailPopup.in_schedule then
                   set
                       bCustConsignDetailPopup.sod_consign_loc
                       bCustConsignDetailPopup.sod_intrans_loc
                       bCustConsignDetailPopup.sod_max_aging_days
                       bCustConsignDetailPopup.sod_auto_replenish
                       with frame sod_consign_sched.
               else
                   set
                       bCustConsignDetailPopup.sod_consign_loc
                       bCustConsignDetailPopup.sod_intrans_loc
                       bCustConsignDetailPopup.sod_max_aging_days
                       with frame sod_consign.


               /* VALIDATE CONSIGNMENT LOCATION */
               if bCustConsignDetailPopup.sod_consign_loc = "" then do:

                  /* BLANK NOT ALLOWED */
                  run displayMessage
                      (input "40",
                       input 3).

                   if bCustConsignDetailPopup.in_schedule then
                      next-prompt bCustConsignDetailPopup.sod_consign_loc
                                with frame sod_consign_sched.
                   else
                      next-prompt
                           bCustConsignDetailPopup.sod_consign_loc
                      with frame sod_consign.
                   undo, retry setloop.
               end.
               else do:

                  {gprun.i ""socnval1.p""
                     "(input bCustConsignDetailPopup.sod_consign_loc,
                       input bCustConsignDetailPopup.sod_site,
                       input bCustConsignDetailPopup.in_schedule)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if return-value <> {&SUCCESS-RESULT} then do:
                       if bCustConsignDetailPopup.in_schedule then
                           next-prompt
                                bCustConsignDetailPopup.sod_consign_loc
                           with frame sod_consign_sched.
                       else
                           next-prompt
                                bCustConsignDetailPopup.sod_consign_loc
                           with frame sod_consign.
                       undo, retry setloop.
                  end.
               end.  /* else do */


               /* VALIDATE IN-TRANSIT LOCATION */
               if bCustConsignDetailPopup.sod_intrans_loc <> ""
               then do:

                  {gprun.i ""socnval1.p""
                     "(input bCustConsignDetailPopup.sod_intrans_loc,
                       input bCustConsignDetailPopup.sod_site,
                       input bCustConsignDetailPopup.in_schedule)"}
/*GUI*/ if global-beam-me-up then undo, leave.


                  if return-value <> {&SUCCESS-RESULT} then do:
                       if bCustConsignDetailPopup.in_schedule then
                           next-prompt
                                bCustConsignDetailPopup.sod_intrans_loc
                           with frame sod_consign_sched.
                       else
                           next-prompt
                                bCustConsignDetailPopup.sod_intrans_loc
                           with frame sod_consign.
                       undo, retry setloop.
                  end.
               end.  /* if intrans_loc <> "" */

               run updateSalesOrderDetailConsignRecord
                   (buffer bCustConsignDetailPopup).


           end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* setloop */

       end.
/*GUI*/ if global-beam-me-up then undo, leave.
  /* repeat */

end.  /* if in_update */

if bCustConsignDetailPopup.in_schedule then
   hide frame sod_consign_sched.
else
   hide frame sod_consign.
